package controllers;

import play.mvc.Controller;
import util.HumanSMSUtil;
import util.SMSUtil;

import com.google.appengine.api.urlfetch.HTTPHeader;
import com.google.appengine.api.urlfetch.HTTPResponse;

public class SMS extends Controller {
	public static void send(String destination, String message)
			throws Exception {
		SMSUtil smsMessage = SMSUtil.create(HumanSMSUtil.class).setDestination(
				destination).setText(message).setOriginator("+559188316629");
		HTTPResponse httpResponse = smsMessage.send();

		response.contentType = "text/plain";

		for (HTTPHeader header : httpResponse.getHeaders())
			renderText("header['%s']: %s\n", header.getName(), header
					.getValue());

		renderText("result: " + new String(httpResponse.getContent()));

		// HTTPResponse httpResult =
		// SMSUtil.create().setDestination(destination)
		// .setText(message).setOriginator("+559188316629").sendAsMail();

		// response.contentType = "text/plain";
		// renderText("status code: %d\npayload: %s",
		// httpResult.getResponseCode(), new String(httpResult
		// .getContent(), "ISO8859-1"));
	}
}
